$(() => {
    $(".submit").click(function () {
        let loginName = $("#loginName").val();
        if (!validPhoneNumber(loginName)) {
            Swal.fire({
                text: "请输入正确的登录名(即手机号)",
                icon: "error",iconColor:"#f05b72",
            });
            return false;
        }
        let password = $("#password").val();
        if (!validPassword(password)) {
            Swal.fire({
                text:"请输入正确的密码格式(6-20位字符和数字组合)",
                icon: "error",iconColor:"#f05b72",
            });
            return false;
        }

        //验证
        let params = $("#loginForm").serialize();
        let url = '/personal/login';
        $.ajax({
            type: 'POST',//方法类型
            url: url,
            data: params,
            success: function (result) {
                if (result.code == 200) {
                    window.location.href = '/index';
                } else {
                    Swal.fire({
                        text: result.msg,
                        icon: "error",iconColor:"#f05b72",
                    });
                }
                ;
            },
            error: function () {
                Swal.fire({
                    text: "操作失败",
                    icon: "error",iconColor:"#f05b72",
                });
            }
        });
    });
});



